package main

/**
双向channel转换为单项channel(不能逆向操作)
 */
func main() {
	ch := make(chan int)

	var chIn chan<- int // 定义入向变量
	chIn = ch
	chIn <- 1
	//<-chIn // invalid operation: <-chIn (receive from send-only type chan<- int)
	var chOut <-chan int // 定义出向变量
	chOut = ch
	//chOut <- 1 // invalid operation: chOut <- 1 (send to receive-only type <-chan int)
	<-chOut
}
